local s15__dahe = fk.CreateSkill {
  name = "s15__dahe",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable {
  ["s15__dahe"] = "大喝",
  [":s15__dahe"] = "锁定技，敌方角色准备阶段，若其与你相邻且装备区里有牌，你弃置其装备区里的一张牌。",
  ["#s15__dahe"] = "大喝：弃置 %src 装备区里的一张牌",
  ["$s15__dahe1"] = "喝啊！",
  ["$s15__dahe2"] = "谁敢与我一战！",
}

-- 触发效果：敌方角色准备阶段
s15__dahe:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    -- 检查是否为敌方角色的准备阶段
    if target == player or player.dead or target.dead then
      return false
    end

    -- 检查是否为敌方
    if not player:isEnemy(target) then
      return false
    end

    -- 检查是否为准备阶段
    if target.phase ~= Player.Start then
      return false
    end

    -- 检查是否相邻
    local nextPlayer = player:getNextAlive(false, 1)
    local lastPlayer = player:getLastAlive(false, 1)

    if target ~= nextPlayer and target ~= lastPlayer then
      return false
    end

    -- 检查目标装备区是否有牌
    if #target:getCardIds(Player.Equip) == 0 then
      return false
    end

    return player:hasSkill(self.name)
  end,

  on_cost = function(self, event, target, player, data)
    local room = player.room
    local equipCards = target:getCardIds(Player.Equip)

    if #equipCards == 0 then
      return false
    end

    -- 如果只有一张装备牌，直接选择
    if #equipCards == 1 then
      self.cost_data = equipCards[1]
      return true
    end

    -- 如果有多张装备牌，让玩家选择
    local cardId = room:askToCards(player, {
      min_num = 1,
      max_num = 1,
      skill_name = s15__dahe.name,
      pattern = ".|.|.|equip",
      prompt = "#s15__dahe",
      cancelable = false,
    })
    if #cardId > 0 then
      event:setCostData(self, { cards = cardId })
      return true
    end

    return false
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard({ Fk:getCardById(event:getCostData(self).cards[1]) }, self.name, target, player)
  end,
})

return s15__dahe
